.class public abstract Lcom/netease/newsreader/weibo/PostEntity;
.super Ljava/lang/Object;
.source "PostEntity.java"


# instance fields
.field private final METHOD:Ljava/lang/String;

.field protected accessor:Lnet/oauth/OAuthAccessor;

.field protected autoRedirect:Z

.field protected oauthInfo:Ljava/util/Properties;


# direct methods
.method public constructor <init>(Lnet/oauth/OAuthAccessor;Ljava/util/Properties;)V
    .locals 1
    .parameter "accessor"
    .parameter "oauthInfo"

    .prologue
    .line 40
    const/4 v0, 0x0

    invoke-direct {p0, p1, p2, v0}, Lcom/netease/newsreader/weibo/PostEntity;-><init>(Lnet/oauth/OAuthAccessor;Ljava/util/Properties;Z)V

    .line 41
    return-void
.end method

.method public constructor <init>(Lnet/oauth/OAuthAccessor;Ljava/util/Properties;Z)V
    .locals 1
    .parameter "accessor"
    .parameter "oauthInfo"
    .parameter "autoRedirect"

    .prologue
    .line 43
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 31
    const-string v0, "POST"

    iput-object v0, p0, Lcom/netease/newsreader/weibo/PostEntity;->METHOD:Ljava/lang/String;

    .line 44
    iput-object p1, p0, Lcom/netease/newsreader/weibo/PostEntity;->accessor:Lnet/oauth/OAuthAccessor;

    .line 45
    iput-object p2, p0, Lcom/netease/newsreader/weibo/PostEntity;->oauthInfo:Ljava/util/Properties;

    .line 46
    iput-boolean p3, p0, Lcom/netease/newsreader/weibo/PostEntity;->autoRedirect:Z

    .line 47
    return-void
.end method

.method public static final toString(Ljava/lang/Object;)Ljava/lang/String;
    .locals 1
    .parameter "from"

    .prologue
    .line 95
    if-nez p0, :cond_0

    const/4 v0, 0x0

    :goto_0
    return-object v0

    :cond_0
    invoke-virtual {p0}, Ljava/lang/Object;->toString()Ljava/lang/String;

    move-result-object v0

    goto :goto_0
.end method


# virtual methods
.method protected afterProcessHeader(Lnet/oauth/http/HttpMessage;Ljava/lang/String;Ljava/util/Properties;)Ljava/util/List;
    .locals 6
    .parameter "httpRequest"
    .parameter "url"
    .parameter "postInfo"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lnet/oauth/http/HttpMessage;",
            "Ljava/lang/String;",
            "Ljava/util/Properties;",
            ")",
            "Ljava/util/List",
            "<",
            "Lorg/apache/http/Header;",
            ">;"
        }
    .end annotation

    .prologue
    .line 100
    new-instance v1, Ljava/util/ArrayList;

    invoke-direct {v1}, Ljava/util/ArrayList;-><init>()V

    .line 102
    .local v1, newHeaders:Ljava/util/List;,"Ljava/util/List<Lorg/apache/http/Header;>;"
    iget-object v2, p1, Lnet/oauth/http/HttpMessage;->headers:Ljava/util/List;

    invoke-interface {v2}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v4

    :cond_0
    :goto_0
    invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    if-nez v2, :cond_1

    .line 108
    return-object v1

    .line 102
    :cond_1
    invoke-interface {v4}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/util/Map$Entry;

    .line 103
    .local v0, header:Ljava/util/Map$Entry;,"Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;"
    invoke-interface {v0}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/String;

    const-string v3, "Authorization"

    invoke-virtual {v2, v3}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v2

    if-eqz v2, :cond_0

    .line 106
    new-instance v5, Lorg/apache/http/message/BasicHeader;

    invoke-interface {v0}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/String;

    invoke-interface {v0}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/String;

    invoke-direct {v5, v2, v3}, Lorg/apache/http/message/BasicHeader;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-interface {v1, v5}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_0
.end method

.method protected abstract genEntity(Ljava/util/Properties;)Lorg/apache/http/HttpEntity;
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation
.end method

.method protected generateHeader(Ljava/lang/String;Ljava/util/Properties;)[Lorg/apache/http/Header;
    .locals 7
    .parameter "url"
    .parameter "postInfo"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;,
            Lnet/oauth/OAuthException;,
            Ljava/net/URISyntaxException;
        }
    .end annotation

    .prologue
    .line 81
    invoke-virtual {p0, p1, p2}, Lcom/netease/newsreader/weibo/PostEntity;->getSignProperties(Ljava/lang/String;Ljava/util/Properties;)Ljava/util/List;

    move-result-object v2

    .line 82
    .local v2, list:Ljava/util/List;,"Ljava/util/List<Lnet/oauth/OAuth$Parameter;>;"
    new-instance v4, Lnet/oauth/OAuthMessage;

    const-string v5, "POST"

    const/4 v6, 0x0

    invoke-direct {v4, v5, p1, v2, v6}, Lnet/oauth/OAuthMessage;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/util/Collection;Ljava/io/InputStream;)V

    .line 83
    .local v4, request:Lnet/oauth/OAuthMessage;
    iget-object v5, p0, Lcom/netease/newsreader/weibo/PostEntity;->accessor:Lnet/oauth/OAuthAccessor;

    invoke-virtual {v4, v5}, Lnet/oauth/OAuthMessage;->addRequiredParameters(Lnet/oauth/OAuthAccessor;)V

    .line 86
    sget-object v5, Lnet/oauth/ParameterStyle;->AUTHORIZATION_HEADER:Lnet/oauth/ParameterStyle;

    .line 85
    invoke-static {v4, v5}, Lnet/oauth/http/HttpMessage;->newRequest(Lnet/oauth/OAuthMessage;Lnet/oauth/ParameterStyle;)Lnet/oauth/http/HttpMessage;

    move-result-object v1

    .line 88
    .local v1, httpRequest:Lnet/oauth/http/HttpMessage;
    invoke-virtual {p0, v1, p1, p2}, Lcom/netease/newsreader/weibo/PostEntity;->afterProcessHeader(Lnet/oauth/http/HttpMessage;Ljava/lang/String;Ljava/util/Properties;)Ljava/util/List;

    move-result-object v3

    .line 89
    .local v3, newHeaders:Ljava/util/List;,"Ljava/util/List<Lorg/apache/http/Header;>;"
    invoke-interface {v3}, Ljava/util/List;->size()I

    move-result v5

    new-array v0, v5, [Lorg/apache/http/Header;

    .line 90
    .local v0, headers:[Lorg/apache/http/Header;
    invoke-interface {v3, v0}, Ljava/util/List;->toArray([Ljava/lang/Object;)[Ljava/lang/Object;

    move-result-object v0

    .end local v0           #headers:[Lorg/apache/http/Header;
    check-cast v0, [Lorg/apache/http/Header;

    .line 91
    .restart local v0       #headers:[Lorg/apache/http/Header;
    return-object v0
.end method

.method public getHttpPost(Ljava/lang/String;Ljava/util/Properties;)Lorg/apache/http/client/methods/HttpPost;
    .locals 6
    .parameter "url"
    .parameter "postInfo"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 53
    new-instance v3, Lorg/apache/http/client/methods/HttpPost;

    invoke-direct {v3, p1}, Lorg/apache/http/client/methods/HttpPost;-><init>(Ljava/lang/String;)V

    .line 55
    .local v3, httppost:Lorg/apache/http/client/methods/HttpPost;
    invoke-virtual {p0}, Lcom/netease/newsreader/weibo/PostEntity;->setAutoRedirect()Lorg/apache/http/params/HttpParams;

    move-result-object v4

    invoke-virtual {v3, v4}, Lorg/apache/http/client/methods/HttpPost;->setParams(Lorg/apache/http/params/HttpParams;)V

    .line 58
    invoke-virtual {p0, p1, p2}, Lcom/netease/newsreader/weibo/PostEntity;->generateHeader(Ljava/lang/String;Ljava/util/Properties;)[Lorg/apache/http/Header;

    move-result-object v2

    .line 59
    .local v2, headers:[Lorg/apache/http/Header;
    if-eqz v2, :cond_0

    .line 60
    array-length v5, v2

    const/4 v4, 0x0

    :goto_0
    if-lt v4, v5, :cond_1

    .line 64
    :cond_0
    invoke-virtual {p0, p2}, Lcom/netease/newsreader/weibo/PostEntity;->genEntity(Ljava/util/Properties;)Lorg/apache/http/HttpEntity;

    move-result-object v0

    .line 65
    .local v0, entity:Lorg/apache/http/HttpEntity;
    invoke-virtual {v3, v0}, Lorg/apache/http/client/methods/HttpPost;->setEntity(Lorg/apache/http/HttpEntity;)V

    .line 66
    return-object v3

    .line 60
    .end local v0           #entity:Lorg/apache/http/HttpEntity;
    :cond_1
    aget-object v1, v2, v4

    .line 61
    .local v1, header:Lorg/apache/http/Header;
    invoke-virtual {v3, v1}, Lorg/apache/http/client/methods/HttpPost;->addHeader(Lorg/apache/http/Header;)V

    .line 60
    add-int/lit8 v4, v4, 0x1

    goto :goto_0
.end method

.method protected abstract getSignProperties(Ljava/lang/String;Ljava/util/Properties;)Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            "Ljava/util/Properties;",
            ")",
            "Ljava/util/List",
            "<",
            "Lnet/oauth/OAuth$Parameter;",
            ">;"
        }
    .end annotation
.end method

.method protected setAutoRedirect()Lorg/apache/http/params/HttpParams;
    .locals 2

    .prologue
    .line 70
    new-instance v0, Lorg/apache/http/params/BasicHttpParams;

    invoke-direct {v0}, Lorg/apache/http/params/BasicHttpParams;-><init>()V

    .line 71
    .local v0, params:Lorg/apache/http/params/HttpParams;
    iget-boolean v1, p0, Lcom/netease/newsreader/weibo/PostEntity;->autoRedirect:Z

    invoke-static {v0, v1}, Lorg/apache/http/client/params/HttpClientParams;->setRedirecting(Lorg/apache/http/params/HttpParams;Z)V

    .line 72
    return-object v0
.end method
